//2859.计算 K 置位下标对应元素的和
//https://leetcode.cn/problems/sum-of-values-at-indices-with-k-set-bits/?envType=daily-question&envId=2024-01-25
class Solution {
public:
    int sumIndicesWithKSetBits(vector<int>& nums, int k) {
        int ret = 0;
        int n = nums.size();
        for(int i = 0;i<n;++i) if(bitset<32>(i).count()==k) ret += nums[i];
        return ret;
    }
};